home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / midifi1a / frmsplas.frm (.txt) < prev    next >
Visual Basic Form  |  1999-10-02  |  6KB  |  162 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSplash 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    ClientHeight    =   2235
  5.    ClientLeft      =   255
  6.    ClientTop       =   1410
  7.    ClientWidth     =   8355
  8.    ClipControls    =   0   'False
  9.    ControlBox      =   0   'False
  10.    Icon            =   "frmSplash.frx":0000
  11.    KeyPreview      =   -1  'True
  12.    LinkTopic       =   "Form2"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   2235
  16.    ScaleWidth      =   8355
  17.    ShowInTaskbar   =   0   'False
  18.    StartUpPosition =   2  'CenterScreen
  19.    Begin VB.FileListBox fillist 
  20.       Height          =   1650
  21.       Left            =   6345
  22.       TabIndex        =   4
  23.       Top             =   0
  24.       Visible         =   0   'False
  25.       Width           =   1950
  26.    End
  27.    Begin VB.DirListBox Dirlist 
  28.       Height          =   1440
  29.       Left            =   0
  30.       TabIndex        =   3
  31.       Top             =   0
  32.       Visible         =   0   'False
  33.       Width           =   2175
  34.    End
  35.    Begin VB.Label Label3 
  36.       Caption         =   "Please wait while i find all of your midi files."
  37.       Height          =   195
  38.       Left            =   0
  39.       TabIndex        =   2
  40.       Top             =   1620
  41.       Width           =   3975
  42.    End
  43.    Begin VB.Label Label2 
  44.       Caption         =   "MIDI PLAY"
  45.       BeginProperty Font 
  46.          Name            =   "Courier New"
  47.          Size            =   36
  48.          Charset         =   0
  49.          Weight          =   400
  50.          Underline       =   0   'False
  51.          Italic          =   0   'False
  52.          Strikethrough   =   0   'False
  53.       EndProperty
  54.       Height          =   690
  55.       Left            =   2295
  56.       TabIndex        =   1
  57.       Top             =   270
  58.       Width           =   4020
  59.    End
  60.    Begin VB.Label Label1 
  61.       Height          =   285
  62.       Left            =   45
  63.       TabIndex        =   0
  64.       Top             =   1890
  65.       Width           =   8250
  66.    End
  67. Attribute VB_Name = "frmSplash"
  68. Attribute VB_GlobalNameSpace = False
  69. Attribute VB_Creatable = False
  70. Attribute VB_PredeclaredId = True
  71. Attribute VB_Exposed = False
  72. Dim SearchFlag As Integer   ' Used as flag for cancel and other operations.
  73. Private Sub cmdSearch_Click()
  74. ' Initialize for search, then perform recursive search.
  75. Dim FirstPath As String, DirCount As Integer, NumFiles As Integer
  76. Dim result As Integer
  77.     FirstPath = Dirlist.Path
  78.     DirCount = Dirlist.ListCount
  79.     ' Start recursive direcory search.
  80.     result = DirDiver(FirstPath, DirCount, "")
  81.     Form1.Show
  82.     Unload Me
  83. End Sub
  84. Private Function DirDiver(NewPath As String, DirCount As Integer, BackUp As String) As Integer
  85. '  Recursively search directories from NewPath down...
  86. '  NewPath is searched on this recursion.
  87. '  BackUp is origin of this recursion.
  88. '  DirCount is number of subdirectories in this directory.
  89. Static FirstErr As Integer
  90. Dim DirsToPeek As Integer, AbandonSearch As Integer, ind As Integer
  91. Dim OldPath As String, ThePath As String, entry As String
  92. Dim retval As Integer
  93.     SearchFlag = True           ' Set flag so the user can interrupt.
  94.     DirDiver = False            ' Set to True if there is an error.
  95.     retval = DoEvents()         ' Check for events (for instance, if the user chooses Cancel).
  96.     If SearchFlag = False Then
  97.         DirDiver = True
  98.         Exit Function
  99.     End If
  100.     On Local Error GoTo DirDriverHandler
  101.     DirsToPeek = Dirlist.ListCount                  ' How many directories below this?
  102.     Do While DirsToPeek > 0 And SearchFlag = True
  103.         OldPath = Dirlist.Path                      ' Save old path for next recursion.
  104.         Dirlist.Path = NewPath
  105.         If Dirlist.ListCount > 0 Then
  106.             ' Get to the node bottom.
  107.             Dirlist.Path = Dirlist.List(DirsToPeek - 1)
  108.             AbandonSearch = DirDiver((Dirlist.Path), DirCount%, OldPath)
  109.         End If
  110.         ' Go up one level in directories.
  111.         DirsToPeek = DirsToPeek - 1
  112.         If AbandonSearch = True Then Exit Function
  113.     Loop
  114.     ' Call function to enumerate files.
  115.     If fillist.ListCount Then
  116.         If Len(Dirlist.Path) <= 3 Then             ' Check for 2 bytes/character
  117.             ThePath = Dirlist.Path                  ' If at root level, leave as is...
  118.         Else
  119.             ThePath = Dirlist.Path + "\"            ' Otherwise put "\" before the filename.
  120.         End If
  121.         For ind = 0 To fillist.ListCount - 1        ' Add conforming files in this directory to the list box.
  122.             entry = ThePath + fillist.List(ind)
  123.             Form1.List1.AddItem entry
  124.             Label1.Caption = entry
  125.             
  126.         Next ind
  127.     End If
  128.     If BackUp <> "" Then        ' If there is a superior directory, move it.
  129.         Dirlist.Path = BackUp
  130.     End If
  131.     Exit Function
  132. DirDriverHandler:
  133.     If Err = 7 Then             ' If Out of Memory error occurs, assume the list box just got full.
  134.         DirDiver = True         ' Create Msg and set return value AbandonSearch.
  135.         MsgBox "You've filled the list box. Abandoning search..."
  136.         Exit Function           ' Note that the exit procedure resets Err to 0.
  137.     Else                        ' Otherwise display error message and quit.
  138.         MsgBox Error
  139.         End
  140.     End If
  141. End Function
  142. Private Sub Dirlist_Change()
  143.   fillist.Path = Dirlist.Path
  144. End Sub
  145. Private Sub DirList_LostFocus()
  146.     Dirlist.Path = Dirlist.List(Dirlist.ListIndex)
  147. End Sub
  148. Private Sub Form_Load()
  149. fillist.Pattern = "*.mid"
  150. Dirlist.Path = "C:\"
  151. Dirlist.Refresh
  152. Me.Show
  153. Dim FirstPath As String, DirCount As Integer, NumFiles As Integer
  154. Dim result As Integer
  155.     FirstPath = Dirlist.Path
  156.     DirCount = Dirlist.ListCount
  157.     ' Start recursive direcory search.
  158.     results = DirDiver(FirstPath, DirCount, "")
  159.     Form1.Show
  160.     Unload Me
  161. End Sub
  162.